﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace Puzzler.Plugin.Interface.Attributes
{
    /// <summary>
    /// Attribute to mark class as Puzzle Plugin
    /// Contains the puzzle plugin informations. Must be defined on the plugin class!
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public sealed class PuzzlePluginAttribute : Attribute
    {
        public String Name { get; private set; }
        public String Description { get; private set; }
        public PuzzleCategory Category { get; private set; }
        public String Note { get; private set; }
        public String IconUri { get; private set; }

        public PuzzlePluginAttribute(string name, string description, PuzzleCategory category, string note, String iconUri)
        {
            Name = name;
            Description = description;
            Category = category;
            Note = note;
            IconUri = iconUri;
        }

        private bool Equals(PuzzlePluginAttribute other)
        {
            return base.Equals(other) && string.Equals(Name, other.Name) && string.Equals(Description, other.Description) && Category.Equals(other.Category) && string.Equals(Note, other.Note) && string.Equals(IconUri, other.IconUri);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return obj is PuzzlePluginAttribute && Equals((PuzzlePluginAttribute) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = base.GetHashCode();
                hashCode = (hashCode*397) ^ (Name != null ? Name.GetHashCode() : 0);
                hashCode = (hashCode*397) ^ (Description != null ? Description.GetHashCode() : 0);
                hashCode = (hashCode*397) ^ Category.GetHashCode();
                hashCode = (hashCode*397) ^ (Note != null ? Note.GetHashCode() : 0);
                hashCode = (hashCode*397) ^ (IconUri != null ? IconUri.GetHashCode() : 0);
                return hashCode;
            }
        }

        public override string ToString()
        {
            return string.Format("Category: {0}, Description: {1}, IconUri: {2}, Name: {3}, Note: {4}", Category, Description, IconUri, Name, Note);
        }
    }
}
